package com.ruangong.GitClient.app.TravelExpense;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.ruangong.GitClient.R;

public class TotalExpenseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_totalexpense);

        // 获取从 Intent 中传递过来的总费用
        double totalExpense = getIntent().getDoubleExtra("TOTAL_EXPENSE", 0.0);
        int numberOfPeople = getIntent().getIntExtra("NUMBER_OF_PEOPLE", 1); // 默认为1，避免除以0的情况


        // 计算每人平均费用
        double averageExpense = totalExpense / numberOfPeople;

        // 找到布局文件中的 TextView
        TextView textViewTotalExpense = findViewById(R.id.textViewTotalExpense);
        TextView textViewAverageExpense = findViewById(R.id.textViewAverageExpense);

        // 将总费用和每人平均费用设置给对应的 TextView
        textViewTotalExpense.setText(String.format("总费用: %.2f元", totalExpense));
        textViewAverageExpense.setText(String.format("人均费用: %.2f元", averageExpense));
    }
}
